package com.bpz.utils;


import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValidateUtils {
    static boolean flag = false;
    static String regex = "";

    public ValidateUtils() {
    }

    public static boolean check(String str, String regex) {
        try {
            Pattern e = Pattern.compile(regex);
            Matcher matcher = e.matcher(str);
            flag = matcher.matches();
        } catch (Exception var4) {
            flag = false;
        }

        return flag;
    }

/*    public static boolean isEmpty(String str) {
        regex = "^\\s*$";
        return check(str, regex);
    }*/

    public static boolean isEmail(String email) {
        String regex = "^\\w+[-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$ ";
        return check(email, regex);
    }

    public static boolean isMobileNum(String cellphone) {
        String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0-9])|(177))\\d{8}$";
        return check(cellphone, regex);
    }

    public static boolean isTelephone(String telephone) {
        String regex = "^(0\\d{2}-\\d{8}(-\\d{1,4})?)|(0\\d{3}-\\d{7,8}(-\\d{1,4})?)$";
        return check(telephone, regex);
    }

    public static boolean isFax(String fax) {
        String regex = "^(0\\d{2}-\\d{8}(-\\d{1,4})?)|(0\\d{3}-\\d{7,8}(-\\d{1,4})?)$";
        return check(fax, regex);
    }

    public static boolean isQQ(String QQ) {
        String regex = "^[1-9][0-9]{4,} $";
        return check(QQ, regex);
    }

}
